import Vue from 'vue';

const state = {
    data: {

    }
};

const getters = {
    data(state) {
        return state.data;
    },
    userCenter(state) {
        return state.data;
    }
};

const mutations = {
    data(state, data) {
        state.data = data;
    },
};

const actions = {
    data(context) {
        Vue.prototype.$request({
            url: Vue.prototype.$api.user.config,
        }).then(res => {
            let { data, code } = res;
            if (code === 0) {
                let config = data.config;
				// 新增俩个选项
				data.config.user_center.menus = [...data.config.user_center.menus, ...[ 
				// {
				// 	icon_url: "http://m.yflbp.com/web/uploads/thumbs/mall1/20221216/ad8d1deae47793121a092499ba7e8e01.png",
				// 	key: "jiangjin",
				// 	link_url: "/pages/new_page/bonus",
				// 	name: "补贴池",
				// 	open_type: "navigate"
				// },{
				// 	icon_url: "http://m.yflbp.com/web/uploads/thumbs/mall1/20221216/ad8d1deae47793121a092499ba7e8e01.png",
				// 	key: "jiangjin1",
				// 	link_url: "/pages/new_page/bonus_record",
				// 	name: "补贴金",
				// 	open_type: "navigate"
				// },{
				// 	icon_url: "http://m.yflbp.com/web/uploads/thumbs/mall1/20221216/ad8d1deae47793121a092499ba7e8e01.png",
				// 	key: "jiangjin2",
				// 	link_url: "/pages/new_page/contribute",
				// 	name: "贡献值",
				// 	open_type: "navigate"
				// },
				{
					icon_url: "http://m.yflbp.com/web/statics/img/mall/share-custom/img-share-team.png",
					key: "jiangjin2",
					link_url: "/pages/share/team/team",
					name: "团队",
					open_type: "navigate"
				},
				{
					icon_url: "http://m.yflbp.com/web/uploads/thumbs/mall1/20221216/ad8d1deae47793121a092499ba7e8e01.png",
					key: "jiangjin3",
					link_url: "/pages/balance/buhuo",
					name: "保证金",
					open_type: "navigate"
				}]]
                if (data && config && config.user_center) {
                    context.commit('data', config.user_center);
                }
            }
        });
    },
};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}
